<template>
	<view class="active-mine">
		<detail-head url="../active/active" type="none"></detail-head>
		<view class="maine">
			<app-title text="预约列表" :width="64"></app-title>
			<view class="list">
				<view class="item" v-for="item in listData" :key="item.id"
					@click="$tool.navigateTo(`/pages/active/list?id=${item.activityId}&activeId=${item.id}`)">
					<text class="title">{{item.title}}</text>
					<text class="valid">{{item.reserveStatusName}}</text>
				</view>
			</view>
			<view class="hint">没有更多数据了~</view>
		</view>
	</view>
</template>

<script>
	import {
		getMyReserve
	} from '../../request/active-api.js'
	export default {
		data() {
			return {
				// 列表数据
				listData: []
			}
		},
		created() {
			this.onLoadListData()
		},
		methods: {
			// 加载 数据
			async onLoadListData() {
				try {
					let {
						code,
						message,
						data
					} = await getMyReserve()
					if (code === 200) {
						this.listData.push(...data)
					} else {
						uni.showToast({
							title: message,
							icon: 'none'
						})
					}
				} catch {
					uni.showToast({
						title: '服务繁忙',
						icon: 'error'
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.active-mine {
		width: 100%;
		min-height: 100vh;
		background: $login-background-url no-repeat;
		background-size: 100% 100%;
		background-position: 0 -40px;
	}

	.maine {
		width: 100%;
		padding: 20px;

		.list {
			width: 100%;
			margin-top: 40rpx;

			.item {
				width: 100%;
				height: 90rpx;
				padding: 0 20rpx;
				margin-bottom: 30rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				background: $active-item-back-url no-repeat;
				background-size: 100% 100%;
				background-position: 0 0;

				.title {
					font-size: 16px;
					font-family: PingFangSC-Semibold, PingFang SC;
					font-weight: 600;
					color: #9D9D9D;
				}

				.valid {
					font-size: 14px;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #979797;
				}
			}
		}

		.hint {
			width: 100%;
			color: #606266;
			font-size: 28rpx;
			text-align: center;
		}
	}
</style>
